export default {
	methods: {
		//直接回复
		async directComment(textInputValue) {
			let data = {
				content_detail: textInputValue
			}
			if (this.options.tid) {
				data.tid = this.options.tid;
			}
			if (this.pid) {
				data.pid = this.pid;
			}
			console.log("direct-comment, data: ", data);
			let res = await this.$api.createComment(data);
			if (res.ret === 0) {
			  this.$store.commit('setNewComment', res.data.data[0])
			  this.textInputValue = ''
			  this.checkNewComment();
			}
		},
		//检查新回复，并定位
		checkNewComment() {
			let newComment = this.$store.getters.getNewComment
			console.log(`newComment: `, newComment)
			if (!newComment) {
				return
			}
			//新发布了新回复，删除标识，追加到最底端
			//添加尾部，不定位
			this.list.push(newComment);
			//滚动到底部
			var query = uni.createSelectorQuery();
			//目标元素的信息
			query.select('#comment-box').boundingClientRect();
			//视图的信息
			query.selectViewport().boundingClientRect();
			query.exec( res => {
				console.log(res);
				this.$store.commit('setNewComment', null)
				if (res[0]) {
				  uni.pageScrollTo({
					scrollTop: res[0].height
				  })
				}
			})
		}
	}
}